import {
  IUpdatePassword,
  IUser,
  IUserLogin,
  IUserQuery,
} from "../RequestIDL/userType";
import createReq from "../request";
import { ContentType, Method } from "../type";
//  新增用户接口
export const userCreate = (data?: Partial<IUser>) => {
  return createReq({
    method: Method.POST,
    url: "/user/register",
    data,
  });
};
// 用户登录接口
export const userLogin = (data: Partial<IUserLogin>) => {
  return createReq({
    method: Method.POST,
    url: "/user/login",
    data,
  });
};
//  批量查询用户接口
export const userBatchQuery = (data: IUserQuery) => {
  return createReq({
    method: Method.POST,
    url: "/user/searchByConditionPage",
    data,
  });
};
//   单个用户信息查询接口
export const getUserInfoById = (data: any) => {
  const url = `/user/getById`;
  return createReq({ method: Method.POST, url, data });
};
// 用户信息修改接口
export const updateUserInfo = (data?: Partial<IUser>) => {
  return createReq({ method: Method.PUT, url: "/user/updateUser", data });
};
// 删除用户信息接口
export const deleteUserInfo = (data?: Partial<IUser>) => {
  const config = { params: data };
  return createReq({
    method: Method.POST,
    url: "/user/delete",
    data,
    config,
  });
};
// 查询本人信息
export const getUserInfoByToken = () => {
  return createReq({ method: Method.GET, url: "/user/myId" });
};
// 修改密码接口
export const updataPassword = (data: IUpdatePassword) => {
  return createReq({
    method: Method.POST,
    url: "/user/updatePassword",
    data,
  });
};
// 接收验证码
export const getVerifiedCode = (data: Partial<IUpdatePassword>) => {
  return createReq({ method: Method.POST, url: "/user/getCode", data });
};
// 重置用户密码
export const resetPassword = (data: any) => {
  return createReq({ method: Method.POST, url: "/user/resetPassword", data });
};
// 用户注销
export const userLogOut = (data: any) => {
  return createReq({ method: Method.GET, url: "/user/logout", data });
};
// 用户批量导入
export const userBatchImport = (data: any) => {
  return createReq({
    method: Method.POST,
    url: "/user/excel",
    data,
    contentType: ContentType.Multipart,
  });
};
